﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CCF20Model.ModelBase;
namespace CCF20Model
{
    public enum ModelName
    {
        SMSModel,
        VehicleModel,
        DeviceModel,
        CustomizeModel,
        CustomerModel,
        FaultModel,
        PermissionModel,
        VehicleMaintenanceModel
    }
    public class ModelFactory
    {
        private SMSModel smsModel;
        private CCF20Entities ccf20Ent;
        private VehicleModel vehicleModel;
        private DeviceModel deviceModel;
        private CustomizeModel customizeModel;
        private CustomerModel customerModel;
        private FaultModel faultModel;
        private PermissionModel permissionModel;
        private VehicleMaintenanceModel vrmModel;
        public ModelFactory()
        {
            ccf20Ent = new CCF20Entities();
        }
        public ModelFactory(CCF20Entities ccf20Entities)
        {
            ccf20Ent = ccf20Entities;
        }
        public ModelBaseClass CreateModel(ModelName modelName)
        {
            switch (modelName)
            {
                case ModelName.FaultModel:

                    faultModel = new FaultModel(ccf20Ent);
                    return faultModel;

                case ModelName.CustomerModel:

                    customerModel = new CustomerModel(ccf20Ent);
                    return customerModel;

                case ModelName.CustomizeModel:

                    customizeModel = new CustomizeModel(ccf20Ent);
                    return customizeModel;

                case ModelName.SMSModel:

                    smsModel = new SMSModel(ccf20Ent);
                    return smsModel;

                case ModelName.VehicleModel:

                    vehicleModel = new VehicleModel(ccf20Ent);
                    return vehicleModel;

                case ModelName.DeviceModel:

                    deviceModel = new DeviceModel(ccf20Ent);
                    return deviceModel;
                case ModelName.PermissionModel:

                    permissionModel = new PermissionModel(ccf20Ent);
                    return permissionModel;
                case ModelName.VehicleMaintenanceModel:

                    vrmModel = new VehicleMaintenanceModel(ccf20Ent);
                    return vrmModel;
                
                default:
                    throw new Exception(string.Format("未知的MODEL{0}", modelName.ToString()));

            }

        }

    }
}
